package com.zx.notification.common.enums;

import lombok.Getter;

/**
 * <p>
 * description: 推送策略枚举定义 <br>
 * create: 2025-10-15 16:45
 * </p>
 *
 * @author zhou  xun
 */
@Getter
public enum PushStrategyEnum {
    REQUIRED("REQUIRED", "必须发送"),
    OPTIONAL("OPTIONAL", "可选发送"),
    FALLBACK("FALLBACK", "备用发送");

    private final String code;
    private final String desc;

    PushStrategyEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * 根据编码获取枚举值
     *
     * @param code 编码
     * @return 枚举值
     */
    public static PushStrategyEnum getEnumByCode(String code) {
        for (PushStrategyEnum value : values()) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        return null;
    }

    /**
     * 根据描述获取枚举值
     *
     * @param desc 描述
     * @return 枚举值
     */
    public static PushStrategyEnum getEnumByDesc(String desc) {
        for (PushStrategyEnum value : values()) {
            if (value.desc.equals(desc)) {
                return value;
            }
        }
        return null;
    }
}